<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<%@include file="/WEB-INF/taglibs/common/taglibs.jsp"%>
<head>
<title><spring:message code="admin.faqanswers.title" /></title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="stylesheet" href="<c:url value="/css/styles.css"/>" />
<script src="<c:url value="/javascripts/common.js"/>"></script>

</head>

<body><%@include file="../top_menu.jsp"%>
<table width="100%">
	<tr>
		<td><c:import url="/WEB-INF/jsp/admin/faq/faq_menu.jsp" />
		</td>
	</tr>
	<tr>
		<td>
			<br/>
			<input type="button" class='ui-button ui-state-default ui-corner-all' value="<spring:message code="admin.faqanswers.button.createanswer" />" onclick="javascript:window.location='create_answer.htm';" />
			<br/>
		</td>
	</tr>	
</table>

<c:if test="${not empty listAnswers}">
	<table class="formTable" width="80%">		
		<tr class="formHeader">
			<td colspan="9"><spring:message code="admin.faqanswers.label.listofanswers" /></td>
		</tr>
		<tr class="formSubHeader">
			<th>#</th>
			<th><spring:message code="admin.faqanswers.label.subject" /></th>
			<th><spring:message code="admin.faqanswers.label.content" /></th>
			<th><spring:message code="admin.faqanswers.label.randintop" /></th>
			<th><spring:message code="admin.faqanswers.label.created" /></th>
			<th><spring:message code="admin.faqanswers.label.lastupdated" /></th>
			<th align="center"><spring:message code="admin.faqanswers.label.actions" /></th>
		</tr>
		
		<c:forEach var="answer" items="${listAnswers}" varStatus="i">
			<tr class="tr_record">
				<td>${i.index+1}</td>
				<td>${answer.subject}</td>
				<td>${answer.answer}</td>
				<td>${answer.topRank}</td>
				<td>${answer.created}</td>
				<td>${answer.updated}</td>
				<td>&nbsp;&nbsp;&nbsp;&nbsp; 
					<input type="button" class='ui-button ui-state-default ui-corner-all'
							value="<spring:message code="admin.faqanswers.button.update" />" onclick="updateAnswer('${answer.id}')" />&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="button" class='ui-button ui-state-default ui-corner-all' value="<spring:message code="admin.faqanswers.button.delete" />"
							onclick="deleteAnswer('${answer.id}')" />
				</td>
			</tr>
		</c:forEach>			
	</table>
</c:if>

<%@include file="/WEB-INF/jsp/include/footer.jsp"%>

<script language="javascript">
	function updateAnswer(id) {
		var updateUrl = "update_answer.htm?id=" + id;
		window.location = updateUrl;		
	}
	
	function deleteAnswer(id) {
		if (confirm('Are you sure you want to delete this answer?')) {
			var deleteUrl = "delete_answer.htm?id=" + id;
			window.location = deleteUrl;
		}
	}
</script>
</body>
</html>